package 
{
    import flash.display.Graphics;
	import flash.display.SimpleButton;
    import flash.display.Sprite;
    import flash.filters.DropShadowFilter;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
	
	/**
     * ...
     * @author Victor Rosales
     */
    public class PlainButton extends SimpleButton
    {
        private var _label:String;

        public function PlainButton(label:String, padding:Number = 10)
        {
            _label = label;

            var chromeUp:Sprite = drawButtonChrome(label, padding, 0xCCCCCC);

            var chromeOver:Sprite = drawButtonChrome(label, padding, 0xAAC3E1);

            var chromeDown:Sprite = drawButtonChrome(label, padding, 0xD6E8FF);

            var chromeHitTest:Sprite = drawButtonChrome(label, padding);

            upState = chromeUp;
            overState = chromeOver;
            downState = chromeDown;
            hitTestState = chromeHitTest;

            //var myFilters:Array = new Array();
            //myFilters.push(new DropShadowFilter(0, 45, 0, 0.25, 10, 10));
            //filters = myFilters;
        }


        private function drawButtonChrome(label:String = "Button", padding:Number = 10 , color:Number = 0xCCCCCC):Sprite
        {
            var text:TextField = new TextField();
            text.text = label;
            text.setTextFormat( new TextFormat("Verdana"));
            text.autoSize = TextFieldAutoSize.LEFT;

            text.x = padding / 2;
            text.y = padding / 2;

            var chrome:Sprite = new Sprite();
            var g:Graphics = chrome.graphics;
            g.lineStyle(1.5, 0x777777);
            g.beginFill(color);
            g.drawRoundRect(0, 0, text.width + padding, text.height + padding, 13);
            //g.drawRect(0, 0, text.width + padding, text.height + padding);
            g.endFill();

            chrome.addChild(text);

            return chrome;
        }

        public function get label():String
        {
            return _label;
        }

    }

}
